generator.return(value) terminates the generator and returns { value, done: true }. generator.throw(error) throws an error inside the generator at the current yield point. Use for cleanup or error handling in consumer code.
return is useful for early termination (e.g., when a user cancels an operation). throw is useful for propagating errors into a generator from external code (e.g., when a network request inside a generator fails and you need to handle it gracefully).